@if (_errors.Any())
{
    @foreach (var error in _errors)
    {
        <AlertMessageError Message="@error" />
    }
}

@code {
    private readonly List<string> _errors = [];

    /// <summary>
    /// Adds a server validation error.
    /// </summary>
    public void AddError(string error)
    {
        _errors.Add(error);
        StateHasChanged();
    }

    /// <summary>
    /// Clears the server validation errors.
    /// </summary>
    public void Clear()
    {
        _errors.Clear();
        StateHasChanged();
    }
}
